#!/bin/bash

for file1 in *

do 
    if [ -d "$file1" ]
    then
        continue
    fi
    
    for file2 in *
    do
        if [ -d "$file2" ] || [ "$file1" = "$file2" ]
        then
            continue
        fi

        differentlines=$(( $(diff -u "$file1" "$file2" | grep ^@ | wc -l) + 1 ))
        lines1=$(($(wc -l < "$file1") + 1 ))
        lines2=$(($(wc -l < "$file2") + 1 ))
        
        if [ -z "$differentlines" ]; then
            differentlines=0
        fi

        if [ -z "$lines1" ]; then
            lines1=0
        fi

        if [ -z "$lines2" ]; then
            lines2=0
        fi
        
        if [ "$lines1" -lt "$lines2" ]
        then
            differentlines=$(( differentlines+lines2 - lines1 ))
        fi

        if [ "$lines2" -lt "$lines1" ]
        then
            differentlines=$(( differentlines+lines1 - lines2 ))
        fi
        
        if [ "$differentlines" -lt "$1" ]
        then
            echo "$file1" "$file2" "$differentlines" "$file1" "$lines1" "$file2" "$lines2"
        fi

    done
done


exit 0
